package com.common.core.exception;


import com.common.core.exception.code.BaseErrorCode;

/**
 * @auther zhangwj
 * @date 2021/7/26 上午11:54
 */
public class ExceptionFactory {

    public static BizException bizException(String errMsg) {
        return new BizException(errMsg);
    }

    public static BizException bizException(int errCode, String errMsg) {
        return new BizException(Integer.toString(errCode), errMsg);
    }

    public static SysException sysException(String errMsg) {
        return new SysException(errMsg);
    }

    public static SysException sysException(String errCode, String errMsg) {
        return new SysException(errCode, errMsg);
    }

    public static SysException sysException(String errMsg, Throwable e) {
        return new SysException(errMsg, e);
    }

    public static SysException sysException(int errCode, String errMsg, Throwable e) {
        return new SysException(Integer.toString(errCode), errMsg, e);
    }

    public static BizException bizException(BaseErrorCode errorCode) {
        return bizException(errorCode.getErrNum(), errorCode.getErrMsg());
    }

    public static SysException sysException(BaseErrorCode errorCode, Throwable e) {
        return new SysException(Integer.toString(errorCode.getErrNum()), errorCode.getErrMsg(), e);
    }

    public static SysException sysException(BaseErrorCode errorCode) {
        return new SysException(Integer.toString(errorCode.getErrNum()), errorCode.getErrMsg());
    }
}
